package smlab.utils
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.system.System;
	import flash.text.TextField;
	
	[SWF(width=170,height=100)]
	/**
	 * 鼠标点击stage后把一组随机字符串复制到系统粘贴板
	 * 随机字符串由数字和字母组成
	 * @author simon
	 * 
	 */
	public class ClickRandomNum extends Sprite
	{
		private var t:TextField=new TextField;
		private var a:Array=["a","b","c","d","e","f","g","h","i","j","k","l","m","","n","p","q","r","s","t","u"];
		private var head:String="";
		
		public function ClickRandomNum()
		{
			stage.addEventListener(MouseEvent.CLICK,on);
			t.mouseEnabled=false;
			t.selectable=false;
			addChild(t);
			
			for(var i:int=0;i<4;i++){
				head=head.concat(a[int(Math.random()*a.length)]+int(Math.random()*10));
			}
			
			on(null);
		}
		
		private function on(e:MouseEvent):void
		{
			var n:int=1000+int(Math.random()*1000);
			var s:String="";
			
			for(var i:int=0;i<7;i++){
				var s2:String=a[int(Math.random()*a.length)];
				s=s.concat(s2+i)
			}
			
			t.text=head+s+n;
			t.width=t.textWidth+30;
			
			System.setClipboard(t.text);
		}
	}
}